<template>
  <div>
    <button @click="getStudents">获取学生信息</button>
    <button @click="getCars">获取汽车信息</button>
  </div>
</template>

<script>
import axios from 'axios'
    export default {
        name:'applyAxios',
        methods:{
            getStudents(){  
                // 代理服务器和本机8080端口一样，取数据直接访问代理服务器的8080取就可以 /api代表服务器的一个名字
                axios.get('http://localhost:8080/api/topic/table/tab').then(
                    response =>{
                        console.log("请求成功了",response.data)
                    },
                    error =>{
                        console.log("请求失败了",error.message)
                    },
                )
            },
            getCars(){
                axios.get('http://localhost:8080/runCar/cars').then(
                    response =>{
                        console.log("请求成功了",response.data)
                    },
                    error =>{
                        console.log("请求失败了",error.message)
                    },
                )
            }
        }
    }
</script>

<style>

</style>